package com.laundry.controller;

import com.laundry.dto.ResultDTO;
import com.laundry.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @GetMapping("/list")
    public ResultDTO getMessages(@RequestParam Long userId) {
        System.out.println("获取消息列表, 用户ID: " + userId); // 调试信息
        return messageService.getMessages(userId);
    }

    @GetMapping("/unread")
    public ResultDTO getUnreadCount(@RequestParam Long userId) {
        System.out.println("获取未读消息数量, 用户ID: " + userId); // 调试信息
        return messageService.getUnreadCount(userId);
    }

    @PutMapping("/read/{id}")
    public ResultDTO readMessage(@PathVariable Long id) {
        System.out.println("标记消息已读, 消息ID: " + id); // 调试信息
        return messageService.readMessage(id);
    }
} 